import requests


class Test_log():
    def test_01(self):
        url="http://ihrm-test.itheima.net/api/sys/login"
        heads={"Content-Type": "application/json"}
        body={"mobile": "13800000002", "password": "123456"}

        resp=requests.post(url,headers=heads,json=body)

        assert resp.status_code==200
        assert resp.json().get("message")=="操作成功！"
        assert resp.json().get("code")==10000
        assert resp.json().get("success")==True

        # 一条测试用例一个方法 密码错误
    def test_02(self):
        url = "http://ihrm-test.itheima.net/api/sys/login"
        heads = {"Content-Type": "application/json"}
        body = {"mobile": "13800000002", "password": "12345"}

        resp = requests.post(url, headers=heads, json=body)
        print(resp.json())

        assert resp.status_code == 200
        assert resp.json().get("message") == "用户名或密码错误"
        assert resp.json().get("code") == 20001
        assert resp.json().get("success") == False

    # 手机号不存在
    def test_03(self):
        url = "http://ihrm-test.itheima.net/api/sys/login"
        heads = {"Content-Type": "application/json"}
        body = {"mobile": "18952369878", "password": "12345"}

        resp = requests.post(url, headers=heads, json=body)
        print(resp.json())

        assert resp.status_code == 200
        assert resp.json().get("message") == "用户名或密码错误"
        assert resp.json().get("code") == 20001
        assert resp.json().get("success") == False

